
import React,{Component} from 'react'
import { Redirect } from 'react-router-dom'
import { Layout } from 'antd'
import {Switch,Route} from 'react-router-dom'


import StrorageUtils from 'utils/storageUtils'
import LeftNav from 'components/left-nav'
import Header from 'components/header'

import Login from 'pages/login'
import DataSrouce from 'pages/data-source'
import CreatingActivity from 'pages/creating-activity'
import ListActivity from 'pages/list-activity'
import AssetTag from 'pages/asset-tag'
import TagRelationship from 'pages/tag-relationship'
import MarketingMonitor from 'pages/marketing-monitor'
import User from '../customer-center/user'
import Role from '../customer-center/role'


const {Sider,Content} = Layout
/**
 * 名称：管理平台主页面
 * 描述：管理平台主页面
 * 调用：
 * 输入：
 * 时间：20220404
 */
class Admin extends Component {
    render (){
        
        const user = StrorageUtils.getUser()
        console.log(user)
        if(!user._id){
            
            return (
                
                   <Switch style={{height:"100vh"}}>
                            <Route path="/login" component={Login}/>
                            <Redirect to="/login"/>
                    </Switch>
                
                   )
            // return <Redirect to = "/admin" />
        }
        return (
        <Layout>
            <Sider 
            style={{
                height: '100vh', //高度与屏幕等高
                position: 'fixed', // 滚动其它页面位置固定不动
            }}>
                <LeftNav/>
            </Sider>
            {/* 如果 LeftNav 设置了位置固定，则其与其它组件不在同一层，content 需要设置margin */}
            <Layout  style={{ marginLeft: 200,minHeight:"100vh"}}> 
                <Header/>
                
                <Content style={{background:"white" ,margin:"20px"}} >
                    <Switch >
                        <Route path="/login" component={Login}/>
                        <Route path="/data-srouce" component={DataSrouce}/>
                        <Route path="/activity-center/creating-activity" component={CreatingActivity}/>
                        <Route path="/activity-center/list-activity" component={ListActivity}/>
                        <Route path="/asset-tag" component={AssetTag}/>
                        <Route path="/marketing-analysis/tag-relationship" component={TagRelationship}/>
                        <Route path="/marketing-analysis/marketing-monitor" component={MarketingMonitor}/>
                        <Route path="/customer-center/user" component={User}/>
                        <Route path="/customer-center/role" component={Role}/>
                        <Route path="/activity-center/edit-activity/:key" component={CreatingActivity}/>
                        <Redirect to="/data-srouce"/>
                    </Switch>
                    
                </Content>
               
            </Layout>
        </Layout>
            )
    }
}
export default Admin